package a2022.a20220712;

/**
 * @author lenovo
 * @date 2022/7/13
 */
public class a {
    public static void main(String[] args) {
        System.out.println(oddCells(2, 3, new int[][]{{0, 1}, {1, 1}}));
    }

    //    public static int oddCells(int m, int n, int[][] ins) {
//        boolean[] r = new boolean[m], c = new boolean[n];
//        int a = 0, b = 0;
//        for (int[] info : ins) {
//            a += (r[info[0]] = !r[info[0]]) ? 1 : -1;
//            b += (c[info[1]] = !c[info[1]]) ? 1 : -1;
//        }
//        return a * (n - b) + (m - a) * b;
//    }
    public static int oddCells(int m, int n, int[][] ins) {
        long c1 = 0, c2 = 0;
        for (int[] info : ins) {
            //运算规则是：两个数转为⼆进制，然后从⾼位开始⽐较，如果相同则为0，不相同则为1
            c1 ^= 1L << info[0];
            c2 ^= 1L << info[1];
        }
        int a = 0, b = 0;
        for (int i = 0; i < m; i++) a += ((c1 >> i) & 1);
        for (int i = 0; i < n; i++) b += ((c2 >> i) & 1);
        return a * (n - b) + (m - a) * b;
    }


}
